from app.storage.storage_record.model import StorageRecord as StorageRecordTable
from app.storage.storage_record import dao
from common.mixins import DictMixin
from common.utils.utils import custom_marshal_pagination
from exts import db


# ------------- route ------------
def create(user_id, **kwargs):
    new_obj = DictMixin.from_dict(StorageRecordTable, kwargs)
    new_obj.creator_id = user_id
    db.session.add(new_obj)
    db.session.commit()
    return new_obj


# def get_by_page(user_id, **kwargs):
#     pagination = dao.get_by_page(**kwargs)
#     pagination = custom_marshal_pagination(pagination)
#     return pagination


def get(user_id, obj_id):
    return StorageRecordTable.query.filter_by(id=obj_id).first()



